Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[android] Fix padding addition #973

Merged

Conversation

mfazekas
Copy link
Contributor

Fixes: #956

@mfazekas
Copy link
Contributor Author

Testcase

import React from 'react';
import {SafeAreaView, Button} from 'react-native';
import MapboxGL, {
  MapView,
  ShapeSource,
  LineLayer,
  Camera,
} from '@react-native-mapbox-gl/maps';

import accessToken from './accesstoken.json';

MapboxGL.setAccessToken(accessToken);

const aLine = {
  type: 'LineString',
  coordinates: [[-74.00597, 40.71427], [-74.00697, 40.71527]],
};

class BugReportExample extends React.Component {
  render() {
    return (
      <SafeAreaView style={{flex: 1, flexDirection: 'column'}}>
        <Button
          title="fitBounds"
          onPress={() => {
            this.camera.fitBounds(
              [-74.00597, 40.71427],
              [-74.00697, 40.71527],
              [0, 0, 300, 0],
            );
          }}
        />
        <Button
          title="fitBounds2"
          onPress={() => {
            this.camera.fitBounds(
              [-74.00597, 40.71427],
              [-74.00697, 40.71527],
              [300, 0, 0, 0],
            );
          }}
        />
        <MapView style={{flex: 1}}>
          <Camera
            centerCoordinate={[-74.00597, 40.71427]}
            zoomLevel={14}
            ref={ref => {
              this.camera = ref;
            }}
          />
          <ShapeSource id="idStreetLayer" shape={aLine}>
            <LineLayer id="idStreetLayer" />
          </ShapeSource>
        </MapView>
      </SafeAreaView>
    );
  }
}

export default BugReportExample;

example/package.json Outdated Show resolved Hide resolved
@sunny-lirr
Copy link

sunny-lirr commented Jul 31, 2020

This essentially reverts #202. Has the iOS behavior changed to make that unnecessary? It seems almost like we fix one or the other, since they're opposites.

@mfazekas
Copy link
Contributor Author

mfazekas commented Aug 2, 2020

@sunny-lirr

This essentially reverts #202. Has the iOS behavior changed to make that unnecessary? It seems almost like we fix one or the other, since they're opposites.

But since #202

  1. there were changes in how mapbox adds camera padding
  2. that caused PaddingBottom on Camera fitBounds does not work anymore #841
  3. which was fixed by Fix android padding #941
  4. But that fix caused camera fitBounds adds padding every time it is called on android #956.
  5. And this PR attempts to fix camera fitBounds adds padding every time it is called on android #956.

I'll try to see how this PR works with issue mentioned in #201.

Padding on iOS is currently broken see #841 and i don't see an easy way to work around that - see underlying issue.

@mfazekas mfazekas force-pushed the mfazekas/fix-padding-android-add branch from 12d1ba6 to 51567e4 Compare August 2, 2020 16:24
@mfazekas
Copy link
Contributor Author

mfazekas commented Aug 2, 2020

@sunny-lirr
i've changed the PR so that contentInset is now added to padding. (But unlinke #202 we don't add previous padding but only content inset)

@mfazekas mfazekas merged commit f0d6f2f into rnmapbox:master Aug 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

camera fitBounds adds padding every time it is called on android
3 participants